#ifndef User_H
#define User_H

#include <iostream>
#include <string>
// 本头文件是数据库类的映射，非常简单，所以所有的声明和实现都放在这里
class User
{
public:
    // id是自增主键，我们无法在构造函数这里设置，后面调用mysql对C++提供的api设置
    User(int id = -1, std::string name = "", std::string password = "123456", std::string state = "offline")
    {
        this->id = id;
        this->name = name;
        this->password = password;
        this->state = state;
    }

    void setId(int id) { this->id = id; }
    void setName(std::string name) { this->name = name; }
    void setPassword(std::string password) { this->password = password; }
    void setState(std::string state) { this->state = state; }

    int getId() { return this->id; }
    std::string getName() { return this->name; }
    std::string getPassword() { return this->password; }
    std::string getState() { return this->state; }

private:
    // 由于要和mysql表上的数据一致，这里就和mysql -- User表一样的命名了
    int id;
    std::string name;
    std::string password;
    std::string state;
};

#endif
